package cn.net.yugu.doraemon.common.util;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author xiangzhurui
 * @version 2023/3/3 16:01:36
 */
@Slf4j
@RequiredArgsConstructor
public class ExecutorSupport {

    /**
     * 默认核心线程数，最少为 2
     *
     * @return
     */
    public static int getDefaultCorePoolSize() {
        final int availableProcessors = Runtime.getRuntime().availableProcessors();
        return availableProcessors < 2 ? 2 : availableProcessors;
    }
}
